/**
 * Program  : MainActivity.java
 * Author   : qianj
 * Create   : 2012-6-12 下午2:30:23
 *
 * Copyright 2012 by newyulong Technologies Ltd.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of newyulong Technologies Ltd.("Confidential Information").  
 * You shall not disclose such Confidential Information and shall 
 * use it only in accordance with the terms of the license agreement 
 * you entered into with newyulong Technologies Ltd.
 *
 */

package cn.colorful.olympic.activity;

import java.util.ArrayList;
import java.util.List;

import cn.colorful.olympic.R;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;

/**
 * 
 * @author   qianj
 * @version  1.0.0
 * @2012-6-12 下午2:30:23
 */
public class MainActivity extends BaseFrameActivity{
	
	LocalActivityManager manager = null;
	int index = 0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		
		List<View> viewList = new ArrayList<View>();
		
		
		manager = new LocalActivityManager(this, true);
		manager.dispatchCreate(savedInstanceState);
		
		
		viewList.add(getView("index",new Intent(this,IndexActivity.class)));
		viewList.add(getView("list",new Intent(this,ListActivity.class)));
		viewList.add(getView("news",new Intent(this,NewsActivity.class)));
		viewList.add(getView("user",new Intent(this,UserActivity.class)));
		
		//初始化切换的activity
		initViewPager(viewList);
		
		
	}
	
	
	private View getView(String id, Intent intent) {
		return manager.startActivity(id, intent).getDecorView();
	}
	
	
	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.radio_button1:
			SetTitle("首页");
			setTitleBar(-1, "", -1, "");
			index = 1;
			break;
		case R.id.radio_button2:
			SetTitle("金牌榜");
			index = 2;
			break;
		case R.id.radio_button3:
			SetTitle("奥运新闻");
			index = 3;
			break;
		case R.id.radio_button4:
			SetTitle("个人");
			index = 4;
			break;
		
		default:
			break;
		}
		
		setCurrentTab(index - 1);
		
	}

	@Override
	protected void handleTitleBarEvent(int buttonId) {
		// TODO Auto-generated method stub
		
	}

}

